//
//  TypeModel.m
//  Project_A
//
//  Created by 徐继垚 on 15/7/17.
//  Copyright (c) 2015年 zhoukaidong. All rights reserved.
//

#import "TypeModel.h"
#import "AFNet.h"


@implementation TypeModel
+ (void)getDataWithBlovk:(TypeDataBlock)block
{
    
    [AFNet connectNetGetDataWithURLString:@"http://api.liwushuo.com/v1/channel_groups/all" parameters:nil finishblock:^(id result) {
       
         NSMutableArray * array1 = [NSMutableArray array];
          NSMutableArray * array2 = [NSMutableArray array];
          NSMutableArray * array3 = [NSMutableArray array];
          NSMutableArray * array4 = [NSMutableArray array];
        
        NSDictionary * dic = [result objectForKey:@"data"];
        NSArray * arr = [dic objectForKey:@"channel_groups"];
        for (NSDictionary * dicc in [arr[0] objectForKey:@"channels"]) {
            TypeModel * model = [[TypeModel alloc]init];
            model.myid = [dicc objectForKey:@"id"];
            model.icon = [dicc objectForKey:@"icon_url"];
            model.aname = [dicc objectForKey:@"name"];
          
            [array1 addObject:model];
         }
        for (NSDictionary * dicc in [arr[1] objectForKey:@"channels"]) {
            TypeModel * model = [[TypeModel alloc]init];
            model.myid = [dicc objectForKey:@"id"];
            model.icon = [dicc objectForKey:@"icon_url"];
            model.aname = [dicc objectForKey:@"name"];
            [array2 addObject:model];
        }
        for (NSDictionary * dicc in [arr[2] objectForKey:@"channels"]) {
            TypeModel * model = [[TypeModel alloc]init];
            model.myid = [dicc objectForKey:@"id"];
            model.icon = [dicc objectForKey:@"icon_url"];
            model.aname = [dicc objectForKey:@"name"];
            [array3 addObject:model];
        }
        for (NSDictionary * dicc in [arr[3] objectForKey:@"channels"]) {
            TypeModel * model = [[TypeModel alloc]init];
            model.myid = [dicc objectForKey:@"id"];
            model.icon = [dicc objectForKey:@"icon_url"];
            model.aname = [dicc objectForKey:@"name"];
            [array4 addObject:model];
        }
        
        
        
    
        block(array1,array2,array3,array4);
        
        
        
        
        
        
    }];
    
    
    
    
    
    
}
@end
